package org.fixies.spreadsheet.excel.poi;

import org.apache.poi.hssf.usermodel.HSSFCell;

/**
 * HSSFのセル値を文字列に変換するコンバータデフォルトクラス
 *
 * @author Kawasaki
 */
public class DefaultHSSFCellValueConverter extends AbstractHSSFCellValueConverter {

    /**
     * コンストラクタ
     *
     * @param filter フィルタ
     */
    public DefaultHSSFCellValueConverter() {
    }

    /**
     * @see org.fixies.spreadsheet.excel.poi.AbstractHSSFCellValueConverter#inCaseCellTypeString(org.apache.poi.hssf.usermodel.HSSFCell)
     */
    public String inCaseCellTypeString(HSSFCell cell) {
        return cell.getRichStringCellValue().getString();
    }

    /**
     * @see org.fixies.spreadsheet.excel.poi.AbstractHSSFCellValueConverter#inCaseCellTypeNumeric(org.apache.poi.hssf.usermodel.HSSFCell)
     */
    public String inCaseCellTypeNumeric(HSSFCell cell) {
        throw new IllegalArgumentException(
                "Excel sheet has numeric cells. value = "
                        + cell.getNumericCellValue());
    }

    /**
     * @see org.fixies.spreadsheet.excel.poi.AbstractHSSFCellValueConverter#inCaseCellTypeBoolean(org.apache.poi.hssf.usermodel.HSSFCell)
     */
    public String inCaseCellTypeBoolean(HSSFCell cell) {
        return Boolean.toString(cell.getBooleanCellValue());
    }

    /**
     * @see org.fixies.spreadsheet.excel.poi.AbstractHSSFCellValueConverter#inCaseCellTypeBlank(org.apache.poi.hssf.usermodel.HSSFCell)
     */
    public String inCaseCellTypeBlank(HSSFCell cell) {
        return "";
    }

    /**
     * @see org.fixies.spreadsheet.excel.poi.AbstractHSSFCellValueConverter#inCaseCellTypeError(org.apache.poi.hssf.usermodel.HSSFCell)
     */
    public String inCaseCellTypeError(HSSFCell cell) {
        return inCaseDefault(cell);
    }

    /**
     * @see org.fixies.spreadsheet.excel.poi.AbstractHSSFCellValueConverter#inCaseCellTypeFormula(org.apache.poi.hssf.usermodel.HSSFCell)
     */
    public String inCaseCellTypeFormula(HSSFCell cell) {
        return inCaseDefault(cell);
    }

    /**
     * @see org.fixies.spreadsheet.excel.poi.AbstractHSSFCellValueConverter#inCaseDefault(org.apache.poi.hssf.usermodel.HSSFCell)
     */
    public String inCaseDefault(HSSFCell cell) {
        throw new IllegalArgumentException(
                "Invalid cell type"
                        + cell.getNumericCellValue());
    }

}
